<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>用户登陆</title>
	</head>
	<body onkeypress="dwr.util.onReturn(event,loginUser);">
		<div id="loginUser" align="center">
			<form action="">
				<table border="1">
					<tr>
						<td colspan="2" align="center">
							<span>&nbsp;</span><span id="message" >&nbsp;</span>
						</td>
					</tr>
					<tr>
						<td width="30%" align="center">用户名：</td>
						<td width="70%" align="left"><input type="text" id="name" style="width:200px;" /></td>
					</tr>
					<tr>
						<td align="center">密&nbsp;&nbsp;码：</td>
						<td align="left"><input type="password" id="password" style="width:200px;" /></td>
					</tr>
					<tr>
						<td align="center">验证码：</td>
						<td align="left">
							<input type="text" id="checkCode" style="width:135px;" />
							<img border="0px" width="60px" height="20px" id="checkCodeImg" src="image.jsp" 
								style="margin:0px 0px -3px 0px;cursor:pointer;" alt="看不清，点击换图片！" 
								onclick="this.src='image.jsp?time=' + new Date().getTime();" />
						</td>
					</tr>
					<tr>
						<td colspan="2" align="center">
							<input type="button" value="登陆" onclick="loginUser();" />
							<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
							<input type="reset" value="重置" />
						</td>
					</tr>
				</table>
			</form>
		</div>
		<script type="text/javascript" src="scripts/jquery-1.5.min.js"></script>
		<script type="text/javascript" src="scripts/utilTools.js"></script>
		<script type="text/javascript" src="dwr/engine.js"></script>
		<script type="text/javascript" src="dwr/util.js"></script>
		<script type="text/javascript" src="dwr/interface/LoginWeb.js"></script>
		<script type="text/javascript">
			function showMessage(message){
				jQuery("#checkCodeImg").attr("src", "image.jsp?time=" + new Date().getTime());
				jQuery("#password").attr("value", "");
				dwr.util.setValue("message", message);
			}
			dwr.engine.setErrorHandler(showMessage);
			function loginUser(){
				var name = jQuery("#name").attr("value").trim();
				var password = jQuery("#password").attr("value").trim();
				var checkCode = jQuery("#checkCode").attr("value").trim();
				if(name == ""){
					jQuery("#message").text("用户名不能为空！");
					return;
				}else{
					jQuery("#message").text(" ");
				}
				if(password == ""){
					jQuery("#message").text("密码不能为空！");
					return;
				}else{
					jQuery("#message").text(" ");
				}
				if(checkCode == ""){
					jQuery("#message").text("验证码不能为空！");
					return;
				}else{
					jQuery("#message").text(" ");
				}
				LoginWeb.login(name, password, checkCode, function(data){
					if(data){
						window.location.href = "center.html";
					}
				});
			}
		</script>
	</body>
</html>